<template>
  <div style="width: 100%">
    <div id="deawer">
      <v-tableTitle
        :title="$t('wave.savefilter')"
        :btnConfig="btnConfig"
        @cancel="cancel"
        @save="save"
      ></v-tableTitle>
      <div class="detailBox">
        <v-detail ref="detail"></v-detail>
      </div>
    </div>
  </div>
</template>

<script>
import baseMixin from "@/mixins/BaseMixin";
import skipMixin from "@/mixins/SkipMixin";
import tableTitle from "commons/TableTitle";
import detail from "../details/Detail";

export default {
  name: "",
  mixins: [baseMixin, skipMixin],
  data() {
    return {
      newFlag: false,
      routeData: {},
    };
  },
  computed: {
    btnConfig() {
      return [
        { label: this.$t("common.save"), certigier: !this.btnPermNameList.includes('WM05010106'), invalid: "save" },
        { label: this.$t("common.return"), certigier: !this.btnPermNameList.includes('WM05010107'), invalid: "cancel" },
      ];
    },
  },
  created() {},
  methods: {
    //保存按钮
    async save() {
      let detail = this.$refs.detail.detailData;
      if (detail.filtername == "") {
        this.$message.error(this.$tj('wave.filtername','app.emptyMes'));
        return;
      }
      try {
        let res = await this.$api.post(
          `/saveFilterByQuerybuilderdetails`,
          detail
        );
        
          this.$message.success(res.returnMgr);
          this.$store.commit("setRouteData", res.bean);
          this.$router.push({ name: "savefilterDeawer" });
        
      } catch (e) {
        this.$message.error(e);
      }
    },
    //弹框取消
    cancel() {
      this.$router.go(-1);
    },
  },
  mounted() {
    this.routeData = this.$store.state.routeData;
  },
  watch: {},
  components: {
    "v-tableTitle": tableTitle,
    "v-detail": detail,
  },
};
</script>

<style scoped></style>
